﻿using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Ya.Router
{
     public class MultiRouterMiddleWare
    {
        private readonly RequestDelegate _next;
        private readonly ILogger _logger;

        public MultiRouterMiddleWare(RequestDelegate next, ILoggerFactory loggerFactory)
        {
            _next = next;
            _logger = loggerFactory.CreateLogger<MultiRouterMiddleWare>();
        }
        public async Task Invoke(HttpContext context)
        {
            if (context.Request.Method == "GET")
            {
                await _next(context);
                return;
            }
            ProcessorFactory.ProcessRequest(context);            
        }
    }
}
